I’ve used R in both professional and academic settings over the last 6 years1.
There is a lot that R can do. While there are many things I enjoy doing in R, this presentation is about one of my favorite applications – data visualization.
Show code
df <-data.frame(x=c(0, 10), y=c(1, 1), r =c(8,7),who=c("Things R can do","Things I know how to do") )#create scatter plot with circleggplot(data = df) +geom_circle(aes(x0=x,y0=y,r=r,fill=who),alpha=.5)+geom_circle(aes(x0=x,y0=y,r=r))+theme_void()+theme(legend.position ="bottom")+labs(fill=NULL)+scale_fill_brewer(type="qual",palette =6)+coord_fixed()+guides(fill=guide_legend(reverse = T))
Data Visualization
Overview
My aim with data visualization is to make my analysis in R more accessible.
This is most often done via the ggplot2 package in R.
_
Charts
Here are a few examples of ggplot2 visualizations I’ve made.
Show code
squirrels %>%ggplot()+geom_bin2d(aes(y=lat,x=long))+theme_minimal()+coord_map()+labs(x=NULL,y=NULL,fill="Count of\nSquirrels",subtitle="Heat Map of Squirrel Sightings in Central Park",title='Squirrel Town')+theme(legend.position ='right',plot.caption =element_text(hjust =0) )
Here are a few examples of ggplot2 visualizations I’ve made.
Show code
plot_data<-final_dataset %>%filter(circuit_label_type_desc=="Stove/Oven/Range") %>%filter(doy<350) %>%group_by(date,date_2020) %>%summarise(kwh=sum(kwh)) %>%arrange(date) %>%group_by(year(date)) %>%mutate(sma=zoo::rollmean(kwh,30,na.pad = T,align ='right'))p2<-ggplot(plot_data)+geom_smooth(aes(x=date_2020,y=kwh,color=factor(year(date))),linewidth=1.5,method ='loess',span=.17,se=F)+geom_hline(yintercept =0,color=NA)+geom_vline(xintercept =as.Date("2020-03-08"))+labs(x="Day of the Year",y="Smoothed Daily Energy Usage (kWh)",color="Time Period",title="Comparison of Stove Energy Usage by Day of Year", subtitle ="Stove usage increased dramatically when the Pandemic started")+scale_color_brewer(type ="qual",palette =6)+scale_x_date(date_breaks ="1 month",date_labels ="%b",limits =c(as.Date("2020-01-01"),as.Date("2020-09-01")))+theme_minimal()+theme(legend.position ='bottom',panel.grid.minor.x =element_blank() )p2